package com.chx.mapper;

import com.chx.entity.SaleOrderDetails;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @Author cp-月入过万
 * @Date 2025/5/30
 */
@Mapper
public interface SaleOrderDetailMapper {
    @Insert("insert into sale_order_details (order_id, product_id, sale_price, quantity, subtotal) values (#{orderId}, #{productId}, #{salePrice}, #{quantity}, #{subtotal})")
    void insert(SaleOrderDetails saleOrderDetails);

    @Delete("delete from sale_order_details where order_id = #{orderId}")
    void deleteByOrderId(Long orderId);

    @Select("select * from sale_order_details where order_id = #{id}")
    List<SaleOrderDetails> getByOrderId(Long id);

     @Select("select count(*) as total from sale_order_details where product_id= #{id}")
    int getByProductId(Long id);
}
